# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=python2-cjson
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.1.0
pkgrel=2
pkgdesc="Fast JSON encoder/decoder for Python (mingw-w64)"
arch=('any')
license=('LGPL')
url="https://pypi.python.org/pypi/python-cjson/"
depends=("${MINGW_PACKAGE_PREFIX}-python2")
source=("https://pypi.python.org/packages/source/p/python-cjson/python-cjson-${pkgver}.tar.gz")
sha256sums=('a01fabb7593728c3d851e1cd9a3efbd18f72650a31a5aa8a74018640da3de8b3')

prepare() {
  cd "${srcdir}"/python-cjson-${pkgver}
}

build() {
  cd "${srcdir}"/python-cjson-${pkgver}
  # Fix python2 shebang
  sed -i 's|#!/usr/bin/python|#!/usr/bin/env python2|' jsontest.py
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

package() {
  cd "${srcdir}"/python-cjson-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=;--install-purelib=;--install-data=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --optimize=1
  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
